package com.hanrui.android.fragment.message.myvote;

import android.os.Bundle;
import android.view.View;
import android.widget.ImageView;
import android.widget.LinearLayout;
import android.widget.TextView;

import com.hanrui.android.R;
import com.hanrui.android.activity.download.MyDownLoadActivity;
import com.hanrui.android.library.base.BaseFragment;
import com.hanrui.android.model.FilesBean;
import com.hanrui.android.model.MyVoteDetailBean;
import com.hanrui.android.net.contract.message.myvote.MyVoteDetailContract;
import com.hanrui.android.net.presenter.message.myvote.MyVoteDetailPresenter;

import java.util.ArrayList;
import java.util.List;

import butterknife.BindView;
import butterknife.OnClick;

/**
 * 董事会表决基本信息
 *
 */

public class MyVoteDetailFragment extends BaseFragment<MyVoteDetailPresenter> implements MyVoteDetailContract.View {
    @BindView(R.id.main_title)
    TextView mainTitle;
    @BindView(R.id.subhead_title)
    TextView subheadTitle;
    @BindView(R.id.enclosure_ll)
    LinearLayout enclosureLl;
    @BindView(R.id.enclosure)
    ImageView enclosure;
    @BindView(R.id.name)
    TextView name;
    @BindView(R.id.thing_title)
    TextView thingTitle;
    @BindView(R.id.time)
    TextView time;
    @BindView(R.id.leaders)
    TextView leaders;
    @BindView(R.id.head_company)
    TextView headCompany;
    @BindView(R.id.from)
    TextView from;
    @BindView(R.id.enclosure_num)
    TextView enclosureNum;

    String mid,type;

    List<FilesBean> filesBeanList = new ArrayList<>();

    @Override
    protected int getLayoutId() {
        return R.layout.fragment_myvotedetail;
    }

    @Override
    protected void initInjector() { mFragmentComponent.inject(this); }

    @Override
    protected void initView(View view) {

        mid = getArguments().getString("mid");
        type = getArguments().getString("type");

        mPresenter.proposalVoteDetail(getActivity(),mid,type);

    }



    public static MyVoteDetailFragment newInstance(String mid, String type) {
        MyVoteDetailFragment fragment = new MyVoteDetailFragment();
        Bundle bundle = new Bundle();
        bundle.putString("mid", mid);
        bundle.putString("type", type);
        fragment.setArguments(bundle);
        return fragment;
    }

    @OnClick({R.id.enclosure})
    public void onViewClicked(View view) {
        switch (view.getId()) {
            case R.id.enclosure:
                MyDownLoadActivity.start(getActivity(),filesBeanList);
                break;
        }
    }

    @Override
    public void proposalVoteDetail(MyVoteDetailBean data) {

        if (null != data) {

            mainTitle.setText("董事会");
            subheadTitle.setText(data.getProposal().getWarningDate());
            name.setText(data.getProposal().getTypeName());
            thingTitle.setText(data.getProposal().getName());
            time.setText(data.getProposal().getWarningDate());
            leaders.setText(data.getProposal().getOaMeetingUserNames());
            headCompany.setText(data.getProposal().getNoticeMessage());
            from.setText(data.getProposal().getRemarks());

            if (null != data.getFiles() && data.getFiles().size() > 0 ) {

                enclosureLl.setVisibility(View.VISIBLE);
                enclosureNum.setText("["+data.getFiles().size()+"]");
                filesBeanList.clear();
                filesBeanList.addAll(data.getFiles());

            		}

        }

    }




}
